package io.renren;

import cn.com.do1.dsf.common.utils.AESEncryptUtils;
import org.junit.Test;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.ArrayList;
import java.util.List;

public class CommonTestUtil {
    @Test
    public void Test5() throws ScriptException {
        String s = "a.length()==1";
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("js");
//        ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("uel");
        scriptEngine.put("a","4");
        Object result = scriptEngine.eval(s);
        Boolean result1 = (Boolean) scriptEngine.eval(s);
        if(result1){
            System.out.println(1);
        }
        System.out.println("结果类型："+result.getClass().getName()+",计算结果："+result);
    }
    @Test
    public void Test4(){
        String a = AESEncryptUtils.encrypt("张三0", "jkl;POIU1234++==");
        System.out.println(a);
        a = AESEncryptUtils.decrypt("QjlSODaLnYcVkjId3KqFAw==", "jkl;POIU1234++==");
        System.out.println(a);
    }
    @Test
    public void Test3(){
        String[] a =new  String[]{"c3c0ae443fce40e1a42fbc192fbe6910","24b038bd6294441aa9f7777a33b9d6c7","aa90af1e08454a448b52532289110aa4","0e68403881f34e7e8fbb280f6a6aa5d9","453b3a886f8e4458a4f30c6e15edeb10","b5907c33062842d28c586aeb70b2300d","041eca2da894419fb3fa274774b30885","b72cef3f91b944b28b73a934b67c3660","11086cd6d9ed46b28574de97185acdce","272156f5dd654f9b9e1ce2021cc83c7d","3c16e964cafe47829ada4bf15f367c0a","f6bc7fa695474484ad9e8a277373ec7c","d57b219554c5430c859de9a4bcad9a05","d86740769b084a87868d2cea69c16649","55641233e164408c8412b12435e16908","b9cd20cfc062480e9e57e55bd1734f7e","24e0cb1609cf45b1a48d28b86b858d25","ebf9d9d8166c473097a1b41605a6bc3e","6041abb1205c4ebd8d2b63df37f0d53a","135e846a742d40ddb10e3f22c20f18ae","fffd797f3c3b4accae118ffeeea2eaf8","36f3317eafe542bb849c742198029a59","f44c214935e9446f912886b563489c0e","0893056973714744a87f953cd3a38aa3","12fe541414d442f38046e518bb3b7b4c","c4de325ad6a14f96a61924b9d4079ee2","bb431cde7c864db396673f1e62781e5f","c4942d0757bb45058bdbaaeac78cc673","ad64c4d7fe7a4ae3a27a6ea7b7f616cf","08d154c663834b4e8bc5313af2f7dbc0","b8c0432b12fc43a5b0015fd98b718770","babe9440590846429eb66b7b2c47f1c0","f0412144326f4c828036230455157fa0","a234c94971a740679201eb7161d34e05","551c2b10d4974d88a348514e0a20163b","7efe274ef6a84636bb6eaf4aeb9ff196","6f078dfe9bf143cd91a3143df098c494","95b49d7558254eb2a321d5497ec906f5","dbbb356147c246debed0329cc66f7cb2","a4ab313a9b984d50ad124fc528757bf7","1dfca69a22924f6bbf98be2ceb0a5b46","2dea4aa1ea17492a8bc84e276018b473","2d6d16e8079041e1a2bf9f67ce1168a2","7323fc21976c44faad6995d3222151d1","455fc438ae9e4c98867ad26976c8e025","7bb4e75175e74bb8b64665876edcf6a9","a920ba9797ba44f68eb3a2a34f2f121d","aa7a78a8baa3471789a576e2bdcb5070","19b91755b7124e378e62cc6263dc4f02","63020caaf5ff4b05b2411e06521f7869","2da1d91d429749b4a1c3ff441d693b97","0fbac627a7cc450283fdff4415c79df3","f8b0a53396344b829db649b2aec05fd8","026bfab030384cff8aff30f54eceaf7e","f947a0696b5945458d369553306d2548","379939199b954e659fa52a42c5a3ca1e","a6290902b7bb48388b64563479b17b50","6219a41eb1444bfeb75e4f5121c6eacc","60cb0905cb784b6ca792b1edcca01ac4","a782f5129191472a9807ddd732b74cd1","97300242ad034c8984a0e4a59a5d6525","49ff18bcddfe4d2c822ceb30fc5f1e3a","f53493e09a974f21b09b1237a04b6d55","cdc96b9f059e4af5b4ad05a3a5519608","3bc573feff0145bbb4a93e7024b74e71","4b610b7c6a42406781ba5e38b5f6c72f","768058fcb60442b086742d88becd83f3","eeb04ceaa6244cf3acb9e50d2d1af25a","4dad28f6dfcb47548d69c626d12d9421","f473ad9ea9284d5eba7e3cad94a5481c","44af42e6faec4eb3b784b3c1549822d6","b05a1f97051749cf93b16b9c49fc80dc","49820eda477a4f58b2261f2af2caeff4","6850e4a4c0bb412788428aadde759663","75e69bb80fa541b4aaeaae69163152f8","4947281316c04f02ab23d5e3147e23ad","08975b1f9cc747c4a4ba6fea9a4ef02d","7b1589a8fbcd49a5bd5d057bb1dabe77","10109f71c4b1498a9e47dad73fc68e6e","058036a0bf8d4168956eb99da0e47eee","7b2c780071c94e17812974fd97554d70","ec6beb3fba374c41a75c1eb2ce2df46e","20080db41e2446028929e0615e8d565b","2e09fcee11684c119bcc68574938c103","667df1d0dfb74f5cb1774f41ffc16218","3d282fd2220b4021864dd5011e036d97","591765c447ce41a69b5dd3d3b6ebd903","66d275b7ee3b4b4281f99af3ea3bc483","5ce43cb6aa334a91b79fcb3419bd8ac9","270164923030413ba4e422f50586ed5b","f7ba3fab55284bbeb2148894ff6d9786","65f0395802c54d72b4f887c8ebafc01d","246c8b21eb2442d98042e2362acb68f0","9345ebce10484159850deefb8c274ddc","dd1a31dab6814fd4b267a2038b2d635a","425dee8751954e019f2b3ae5d5844be2","0a489c1235f349c393b16a6bf11ac613","3e7247f8b18a4a19b2066ac7393640c4","10eeff231ac445c2943e21135980f49a","a1d5b66b896c4c588f5dc7f5f1c81ca3"};
        System.out.println(a.length);
    }
    @Test
    public void Test2(){
        String a = "";
        for(int i=0;i<100;i++){
            a += i+",";
        }
        System.out.println(a);
    }
    @Test
    public void Test1(){
        int maxThreadCount = 5;//最大线程数5
        int batches = 3;//分多少个线程执行
        List<String> notes = new ArrayList<>(12);
        for(int i=0;i<100;i++){
            notes.add(i+"");
        }

        int noteSize = notes.size();
        if (noteSize < batches) {
            batches = 1;
        }
        int groupLen = noteSize  / batches;
        //分组超长最大线程限制，则设置分组数为5，计算分组集合尺寸
        if (batches > maxThreadCount) {
            batches = maxThreadCount;
            groupLen = noteSize  / batches;
        }
        System.out.println("总长度：" + noteSize + "  分为：" + batches + "组  分组长度：" + groupLen);
    }
}
